Skip to content

Fix(lsp-terraform): Adapt keywords to use underscores for lsp-mode core compatibility #4806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

StepaniaH
Copy link

This PR fixes compilation errors in clients/lsp-terraform.el when used with recent versions of lsp-mode 20250531.742`

Fixes #4805

Problem:
The lsp-terraform.el file (which has not been updated in the main repository for approximately a year) started failing to compile. The errors consistently followed the pattern:
Error: Unknown key: :some-key-with-hyphen. Available keys: (... :some_key_with_underscore ...)
This occurred for several multi-word keywords within lsp-defun destructuring forms, such as :docs-link (expected :docs_link) and :provider-requirements (expected :provider_requirements).

This suggests a change in lsp-mode core's keyword handling or its internal type definitions for data related to terraform-ls, now favoring/expecting underscores for these specific multi-word keys.

Solution:
This PR updates the affected keywords in lsp-terraform.el within lsp-defun parameter destructuring (for types like &terraform-ls:Module, &terraform-ls:Providers, etc.) to use the underscore convention, matching the "Available keys" provided in the compilation error messages. Corresponding local variable names have also been updated to use underscores.

These changes allow lsp-terraform.el to compile successfully with the current lsp-mode core.

@github-actions github-actions bot added the client One or more of lsp-mode language clients label May 31, 2025
@jcs090218
Copy link
Member

It looks like there is a compile error: 🤔

Unknown key: :docs_link.  Available keys: (:name :docs-link :version :source-type :dependent-modules)

@StepaniaH
Copy link
Author

It looks like there is a compile error: 🤔

Unknown key: :docs_link.  Available keys: (:name :docs-link :version :source-type :dependent-modules)

It is interesting that when I reproduce it in a clean emacs environment (with emacs version 30.1 and lsp-mode-20250601.129), it shows lsp-terraform.el:305:34: Error: Unknown key: :docs-link. Available keys: (:name :docs_link :version :source_type :dependent_modules).
Screenshot 2025-06-01 at 10 41 29

@psibi
Copy link
Member

psibi commented Jun 2, 2025

These initial changes was originally done by me when implementing the terraform lsp client. IIRC, having it like docs_link didn't work correctly when interacting with the terraform language server. @StepaniaH Can you confirm that you are able to see module information on the terraform code with these changes ?

@StepaniaH
Copy link
Author

These initial changes was originally done by me when implementing the terraform lsp client. IIRC, having it like docs_link didn't work correctly when interacting with the terraform language server. @StepaniaH Can you confirm that you are able to see module information on the terraform code with these changes ?

Actually, I rarely write Terraform-related codes. I modified it only because this compilation error in it caused issues with the overall LSP configuration when I reset my Emacs.

At least for now, the modified code runs well in my environment. And I will try to re-verify and reproduce the issue at a later time in the near future. If there is any further information, I will promptly sync it with you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client One or more of lsp-mode language clients documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lsp-terraform.el fails to compile with recent lsp-mode due to keyword style mismatch
3 participants